#include<string.h>

char *truncateSentence(char *s, int k)
{
    int len = strlen(s), i, cnt = 0;

    for (i = 0; i < len; i++)
    {
        if (s[i] == ' ')
        {
            cnt++;
        }

        if (cnt == k)
        {
            s[i] = '\0';
            return s;
        }
    }

    return s;
}